package com.qfedu.vhr.controller.sys;

import com.qfedu.vhr.common.RespBean;
import com.qfedu.vhr.system.entity.Department;
import com.qfedu.vhr.system.entity.vo.AddDepartmentVO;
import com.qfedu.vhr.system.entity.vo.DepartmentVO;
import com.qfedu.vhr.system.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author baize
 * @date 2023/1/11
 * @site www.qfedu.com
 */
@RestController
@RequestMapping("/system/basic/department")
public class DepartmentController {

    @Autowired
    IDepartmentService departmentService;

    @GetMapping("/")
    public List<DepartmentVO> getAllDeptWithChildren() {
        return departmentService.getAllDeptWithChildren();
    }

    @PostMapping("/")
    public RespBean addDepartment(@RequestBody AddDepartmentVO addDepartmentVO) {
        return departmentService.addDepartment(addDepartmentVO);
    }

    @GetMapping("/all")
    public List<Department> getAll() {
        return departmentService.list();
    }

    @DeleteMapping("/{id}")
    public RespBean deleteDeptById(@PathVariable Integer id) {
        return departmentService.deleteDeptById(id);
    }

}
